﻿DROP TRIGGER IF EXISTS  `pk_shop_config_log` ;   
CREATE   TRIGGER  `pk_shop_config_log` AFTER INSERT ON  `open_shop_config`
  FOR EACH ROW BEGIN

dECLARE pkf varchar(50) DEFAULT "";

sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="shop_config";

if pkf <> "shop_config" then

  INSERT INTO open_pk_log SET pk_from = 'shop_config', pk_id = NEW.id;

eLSE

   update open_pk_log SET pk_id = NEW.id WHERE pk_from = 'shop_config';

end if;

end;